package main.java.chessfootball.rules.checker;

import main.java.chessfootball.model.game.Player;
import main.java.chessfootball.model.regulation.Mode;

/**
 * User: Igor
 * Date: 27.07.2011
 * Time: 8:07:50
 */
public class PlayerClashChecker extends AbstractPutChecker
{

	@Override
	public boolean valid()
	{
		Player player = game.getField().getPlayer(put.getCell());
		if ((player != null) && (player.getNumber() != put.getPlayer()))
		{
			return false;
		}
		if (game.getField().getTeam(put.getSide().getInvert()).contains(put.getCell()))
		{
			return false;
		}
		if ((game.getMatch().getMode().equals(Mode.OUT_GAME)) && (game.getField().getBall().getCell().equals(put.getCell())))
		{
			return false;
		}
		return true;
	}
}
